package cc.jq1024.domain.activity.service.quota.policy.impl;

import cc.jq1024.domain.activity.model.aggregate.CreateQuotaOrderAggregate;
import cc.jq1024.domain.activity.model.valobj.OrderStateVO;
import cc.jq1024.domain.activity.repository.IActivityRepository;
import cc.jq1024.domain.activity.service.quota.policy.ITradePolicy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 积分交易【需要支付】
 * @author li--jiaqiang
 * @date 2024−07−17
 */
@Slf4j
@Service("credit_pay_trade")
@RequiredArgsConstructor
public class CreditTradePolicy implements ITradePolicy {

    private final IActivityRepository activityRepository;

    /**
     * 交易（下单）接口 - 【需要进行支付 - 消耗积分进行兑换】
     * @param createQuotaOrderAggregate 订单聚合对象
     */
    @Override
    public void trade(CreateQuotaOrderAggregate createQuotaOrderAggregate) {
        createQuotaOrderAggregate.setOrderState(OrderStateVO.wait_pay);
        activityRepository.doSaveCreditPayOrder(createQuotaOrderAggregate);
    }
}